package com.ygqh.baby.controller.mobile;

import com.ygqh.baby.ao.SalesPlatform;
import com.ygqh.baby.interceptor.AppExceptionHandler;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BaseController extends AppExceptionHandler {

	final BigDecimal ZERO = new BigDecimal("0.00");

	final static SalesPlatform SALES_PLATFORM = SalesPlatform.Yijiadian;
	final static String PLATFORM_NO = "M001";
	final static String PLATFORM_NAME = "壹家店";

	@InitBinder
	public void initBinder(WebDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); // true:允许输入空值，false:不能为空值
	}
}
